#ifndef __CHAT_SERVER_H__
#define __CHAT_SERVER_H__

#include <map>
#include <memory>
#include <mutex>

#include <boost/asio.hpp>

#include "Session.h"

class Server
{
public:
    Server(boost::asio::io_context& ioc, uint16_t port);
    void DeleteSession(const std::string& sessionId);

private:
    void _StartAccept();
    void _HandleAccept(std::shared_ptr<Session> session, const boost::system::error_code& ec);

private:
    uint16_t _port;
    boost::asio::io_context& _ioc;
    boost::asio::ip::tcp::acceptor _acceptor;
    std::map<std::string, std::shared_ptr<Session>> _sessions;
    std::mutex _sessions_lock;
};


#endif // !__SERVER_H__